package com.sparrow.event;

import com.sparrow.common.thread.IdExecutorGroup;
import com.sparrow.event.api.EventBus;
import com.sparrow.event.core.EventAutoRegister;
import com.sparrow.event.core.EventBusImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.sparrow.event")
public class SparrowEventAutoConfig {
    @Bean
    public EventBus eventBus(IdExecutorGroup idExecutorGroup) {
        EventBusImpl eventBus = new EventBusImpl(idExecutorGroup);
        return eventBus;
    }

    @Bean
    public EventAutoRegister eventAutoRegister(EventBus eventBus) {
        EventAutoRegister register = new EventAutoRegister(eventBus);
        return register;
    }
}

